package com.ebs.gparecorderweb.model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Semester {
	private ArrayList<Course> courses;
	private Season season;
	private int year;
	
	public Semester(Season season, int year){
		
		if(isValidSeason(season)){
			this.season = season;
		}
		else{
			this.season = null;
		}
		
		if(isValidYear(year)){
			this.year = year;
		}
		else{
			this.year = -1;
		}
	}
	
	public boolean isValidSeason(Season season){
		for(Season s : Season.values()){
			if(s.equals(season))
				return true;
		}
		return false;
	}
	
	public boolean isValidYear(int year){
		Calendar c = new GregorianCalendar();
		
		if(year > (c.get(Calendar.YEAR) + 5))
			return false;
		else
			return true;
	}


	public ArrayList<Course> getCourses() {
		return courses;
	}


	public void setCourses(ArrayList<Course> courses) {
		this.courses = courses;
	}


	public Season getSeason() {
		return season;
	}


	public void setSeason(Season season) {
		this.season = season;
	}


	public int getYear() {
		return year;
	}


	public void setYear(int year) {
		this.year = year;
	}
	
}
